import errors from "restify-errors";
import { EntityRepository } from "typeorm";

import { User } from "@src/apps/account/entities/user.entity"
import { ValidateRepository } from "@src/lib/db/postgres/validate.repository";

@EntityRepository(User)
export class UserRepository extends ValidateRepository<User> {
    async getName(): Promise<string|undefined> {
        const user = await this.findOne(0);
        if (user === undefined){
            return 'guest';
        }
        return user.name;
    }
}